home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 November / Chip Kasım 2000.iso / prog / share / 11 / setup.exe / %MAINDIR% / DEMOS / CIFTP / FTPCLASS / FRMFTP.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-09-07  |  24.3 KB  |  672 lines

  1. VERSION 4.00
  2. Begin VB.Form frmFTP 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "FTP Class Demo"
  5.    ClientHeight    =   5430
  6.    ClientLeft      =   2595
  7.    ClientTop       =   2535
  8.    ClientWidth     =   7365
  9.    Height          =   5880
  10.    Icon            =   "FRMFTP.frx":0000
  11.    Left            =   2535
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   5430
  15.    ScaleWidth      =   7365
  16.    Top             =   2145
  17.    Width           =   7485
  18.    Begin VB.TextBox PercentGauge 
  19.       BackColor       =   &H00C0C0C0&
  20.       ForeColor       =   &H00000000&
  21.       Height          =   285
  22.       Left            =   1590
  23.       TabIndex        =   16
  24.       Top             =   5055
  25.       Width           =   570
  26.    End
  27.    Begin VB.TextBox txtStatus 
  28.       BackColor       =   &H00C0C0C0&
  29.       Height          =   360
  30.       Left            =   60
  31.       TabIndex        =   14
  32.       TabStop         =   0   'False
  33.       Text            =   "Ready"
  34.       Top             =   4605
  35.       Width           =   7185
  36.    End
  37.    Begin VB.Frame Frame2 
  38.       Caption         =   "Remote Files"
  39.       Height          =   4365
  40.       Left            =   3090
  41.       TabIndex        =   4
  42.       Top             =   150
  43.       Width           =   4140
  44.       Begin VB.ComboBox cboHostName 
  45.          BackColor       =   &H00FFFFFF&
  46.          Height          =   315
  47.          ItemData        =   "FRMFTP.frx":0442
  48.          Left            =   180
  49.          List            =   "FRMFTP.frx":0452
  50.          TabIndex        =   13
  51.          Text            =   "ftp.progress.com"
  52.          Top             =   360
  53.          Width           =   2535
  54.       End
  55.       Begin VB.ListBox lstFiles 
  56.          Height          =   1425
  57.          Left            =   180
  58.          MultiSelect     =   2  'Extended
  59.          TabIndex        =   12
  60.          Top             =   2745
  61.          Width           =   2535
  62.       End
  63.       Begin VB.ListBox lstDirs 
  64.          Height          =   1845
  65.          IntegralHeight  =   0   'False
  66.          Left            =   180
  67.          TabIndex        =   11
  68.          Top             =   810
  69.          Width           =   2535
  70.       End
  71.       Begin VB.CommandButton cmdLogin 
  72.          Caption         =   "&Login"
  73.          Height          =   370
  74.          Left            =   2925
  75.          TabIndex        =   10
  76.          Top             =   360
  77.          Width           =   960
  78.       End
  79.       Begin VB.CommandButton cmdAbort 
  80.          Caption         =   "&Abort"
  81.          Height          =   370
  82.          Left            =   2925
  83.          TabIndex        =   9
  84.          Top             =   810
  85.          Width           =   960
  86.       End
  87.       Begin VB.CommandButton cmdQuit 
  88.          Caption         =   "&Quit"
  89.          Height          =   370
  90.          Left            =   2925
  91.          TabIndex        =   8
  92.          Top             =   1260
  93.          Width           =   960
  94.       End
  95.       Begin VB.CheckBox chkAutoUpdate 
  96.          Caption         =   "Auto &Update"
  97.          Height          =   420
  98.          Left            =   2835
  99.          TabIndex        =   7
  100.          Top             =   3510
  101.          Width           =   1275
  102.       End
  103.       Begin VB.CheckBox chkBinary 
  104.          Caption         =   "&Binary"
  105.          Height          =   375
  106.          Left            =   2835
  107.          TabIndex        =   6
  108.          Top             =   2655
  109.          Value           =   1  'Checked
  110.          Width           =   1050
  111.       End
  112.       Begin VB.CheckBox chkConfirm 
  113.          Caption         =   "&Confirm"
  114.          Height          =   420
  115.          Left            =   2835
  116.          TabIndex        =   5
  117.          Top             =   3060
  118.          Value           =   1  'Checked
  119.          Width           =   1275
  120.       End
  121.    End
  122.    Begin VB.Frame Frame1 
  123.       Caption         =   "Local Files"
  124.       Height          =   4365
  125.       Left            =   75
  126.       TabIndex        =   0
  127.       Top             =   150
  128.       Width           =   2940
  129.       Begin VB.FileListBox File1 
  130.          Height          =   1425
  131.          Left            =   225
  132.          MultiSelect     =   2  'Extended
  133.          TabIndex        =   3
  134.          Top             =   2715
  135.          Width           =   2535
  136.       End
  137.       Begin VB.DirListBox Dir1 
  138.          Height          =   1830
  139.          Left            =   225
  140.          TabIndex        =   2
  141.          Top             =   810
  142.          Width           =   2535
  143.       End
  144.       Begin VB.DriveListBox Drive1 
  145.          BackColor       =   &H00FFFFFF&
  146.          Height          =   315
  147.          Left            =   225
  148.          TabIndex        =   1
  149.          Top             =   360
  150.          Width           =   2535
  151.       End
  152.    End
  153.    Begin VB.Label Label1 
  154.       Caption         =   "Percent Completed:"
  155.       Height          =   285
  156.       Left            =   60
  157.       TabIndex        =   15
  158.       Top             =   5070
  159.       Width           =   1560
  160.    End
  161.    Begin VB.Image imgDragStart 
  162.       Height          =   480
  163.       Left            =   7515
  164.       Picture         =   "FRMFTP.frx":0498
  165.       Top             =   2115
  166.       Visible         =   0   'False
  167.       Width           =   480
  168.    End
  169.    Begin VB.Image imgInvalid 
  170.       Height          =   480
  171.       Left            =   7515
  172.       Picture         =   "FRMFTP.frx":08DA
  173.       Top             =   1485
  174.       Visible         =   0   'False
  175.       Width           =   480
  176.    End
  177.    Begin CIFTPLib.CIFTP FTP 
  178.       Height          =   450
  179.       Left            =   7470
  180.       Top             =   2835
  181.       Width           =   480
  182.       _Version        =   65537
  183.       _ExtentX        =   847
  184.       _ExtentY        =   794
  185.       _StockProps     =   0
  186.       AccessChannelConnectionWAV=   ""
  187.       AccessChannelClosedWAV=   ""
  188.       DataChannelConnectionWAV=   ""
  189.       DataChannelClosedWAV=   ""
  190.       FileClosedWAV   =   ""
  191.       ListBoxesPopulatedWAV=   ""
  192.       SocketClosedWAV =   ""
  193.       WSAErrorWAV     =   ""
  194.       HostName        =   "ftp.progress.com"
  195.       HostAddress     =   ""
  196.       RemoteFileName  =   ""
  197.       LoginName       =   "anonymous"
  198.       Password        =   "swan@nashua.progress.com"
  199.       RepresentationType=   ""
  200.       WorkingDirectory=   ""
  201.    End
  202. Attribute VB_Name = "frmFTP"
  203. Attribute VB_Creatable = False
  204. Attribute VB_Exposed = False
  205. Option Explicit
  206. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  207. ' SUBJECT:      frmFTP
  208. ' AUTHOR:       David M Swan
  209. '                      Progress Software Corporation
  210. '                      Crescent Division
  211. ' CREATED:     December 8, 1996
  212. ' REVISION
  213. ' HISTORY:
  214. ' DESCRIPTION: Demonstrates how you might use the clsFTP wrapper class
  215. '                         See FtpClass.wri for detailed description of the class.
  216. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217. ' Module scope variable declarations
  218. '==========================
  219. Dim cFTP As New clsFTP ' the CIFTP wrapper class
  220. Dim m_lFileSize As Long ' used to monitor progress of file transfers
  221. Dim m_CurrentControl As Variant ' used by HandleMouseMove to provide UI feedback
  222. Private Sub chkAutoUpdate_GotFocus()
  223.   HandleMouseMove chkAutoUpdate
  224. End Sub
  225. Private Sub chkAutoUpdate_LostFocus()
  226.   HandleMouseMove
  227. End Sub
  228. Private Sub chkAutoUpdate_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  229.   HandleMouseMove chkAutoUpdate
  230. End Sub
  231. Private Sub chkBinary_GotFocus()
  232.   HandleMouseMove chkBinary
  233. End Sub
  234. Private Sub chkBinary_LostFocus()
  235.    HandleMouseMove
  236. End Sub
  237. Private Sub chkBinary_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  238.   HandleMouseMove chkBinary
  239. End Sub
  240. Private Sub chkConfirm_GotFocus()
  241.   HandleMouseMove chkConfirm
  242. End Sub
  243. Private Sub chkConfirm_LostFocus()
  244.   HandleMouseMove
  245. End Sub
  246. Private Sub chkConfirm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  247.  HandleMouseMove chkConfirm
  248. End Sub
  249. Private Sub cmdAbort_Click()
  250.   If Not cFTP.bAbort Then
  251.     UpdateStatus cFTP.sGetLastError, vbRed
  252.   Else
  253.     UpdateStatus "Ready"
  254.   End If
  255. End Sub
  256. Private Sub cmdAbort_GotFocus()
  257.   HandleMouseMove cmdAbort
  258. End Sub
  259. Private Sub cmdAbort_LostFocus()
  260. HandleMouseMove
  261. End Sub
  262. Private Sub cmdAbort_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  263.   HandleMouseMove cmdAbort
  264. End Sub
  265. Private Sub cmdLogin_Click()
  266.   Dim bSuccess As Boolean
  267.   cmdLogin.Enabled = False ' disable button while processing request
  268.   cboHostName.SelLength = 0 ' clear any selected text in host name field (looks better)
  269.   If cmdLogin.Caption = "&Login" Then
  270.     ' Attempt to make an anonymous connection with the host specified
  271.     ' We could easily modify this to use a specific username & password if desired
  272.     UpdateStatus "Connecting to: " & cboHostName.Text
  273.     If Not cFTP.bLogin(cboHostName.Text, "anonymous", "someone@someplace.com") Then
  274.       UpdateStatus cFTP.sGetLastError, vbRed
  275.     Else
  276.       ' modify UI to indicate connection has been made...
  277.       UpdateStatus "Connected to: " & cboHostName.Text
  278.       cmdLogin.Caption = "&Logout"
  279.       cboHostName.Font.Bold = True
  280.       cboHostName.BackColor = vbGreen
  281.       cboHostName.SelLength = 0
  282.       cboHostName.Enabled = False
  283.       GetDirectory ' update the directory listing
  284.     End If
  285.   Else ' we're logging out...
  286.     UpdateStatus "Logging Out Of: " & cboHostName.Text
  287.     DoEvents
  288.     bSuccess = cFTP.bLogout()
  289.     If Not bSuccess Then
  290.       UpdateStatus cFTP.sGetLastError, vbRed
  291.     Else
  292.       DoEvents
  293.     End If
  294.     ' Even if we "failed" to log out, the connection may have been lost (for example,
  295.     ' due to a timeout), so handle this case by resetting the environment if the
  296.     ' access channel has been dropped (as indicated by the result of bLoggedIn)
  297.     If bSuccess Or Not cFTP.bLoggedIn() Then ' This will be True if bLogout succeeded OR if the server dropped the connection
  298.       UpdateStatus "No Connection"
  299.       ' modify UI to indicate that they have logged out of the ftp server...
  300.       lstDirs.Clear
  301.       lstFiles.Clear
  302.       cmdLogin.Caption = "&Login"
  303.       cboHostName.Enabled = True
  304.       cboHostName.BackColor = vbWhite
  305.       cboHostName.Font.Bold = False
  306.       cboHostName.SelLength = 0
  307.       FTP.WorkingDirectory = ""
  308.       frmFTP.Caption = "FTP Class Demo"
  309.     End If
  310.   End If
  311.   cmdLogin.Enabled = True ' re-enable button now that request has been processed
  312. End Sub
  313. Private Sub GetDirectory()
  314.   UpdateStatus "Updating directory listing..."
  315.   If Not cFTP.bGetDirectory Then
  316.     UpdateStatus cFTP.sGetLastError, vbRed
  317.   Else
  318.     UpdateStatus "Ready"
  319.     UpdatePath
  320.   End If
  321. End Sub
  322. Private Sub UpdateStatus(sStatus As String, Optional vntColor)
  323.   ' updates the status information displayed at the bottom of the form
  324.   ' If a color was specified use it, otherwise default to using black
  325.   Dim lColor As Long
  326.   If IsMissing(vntColor) Then lColor = vbBlack Else lColor = CLng(vntColor)
  327.   txtStatus.ForeColor = lColor
  328.   txtStatus.Text = sStatus
  329. End Sub ' UpdateStatus
  330. Private Sub UpdatePath()
  331.    frmFTP.Caption = FTP.WorkingDirectory
  332. End Sub
  333. Private Sub cmdLogin_GotFocus()
  334.   HandleMouseMove cmdLogin
  335. End Sub
  336. Private Sub cmdLogin_LostFocus()
  337.   HandleMouseMove
  338. End Sub
  339. Private Sub cmdLogin_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  340.   HandleMouseMove cmdLogin
  341. End Sub
  342. Private Sub HandleMouseMove(Optional O)
  343.   ' Provide visual feedback to users.
  344.   ' This routine is called when the user moves the mouse
  345.   ' over various interface controls (buttons, checkboxes) in
  346.   ' the remote files area.  If no control is passed in the optional
  347.   ' parameter then the currently highlighted control (if any) is
  348.   ' unhighlighted.
  349.   On Error GoTo HandleMouseMove_ErrHdlr
  350.   ' If no control was passed and no control has been set, then
  351.   ' no action is required
  352.   If IsMissing(O) And IsEmpty(m_CurrentControl) Then Exit Sub
  353.   ' If no control has been passed, but a control has been previously
  354.   ' set, then we need to restore the control to its original state
  355.   If IsMissing(O) And Not IsEmpty(m_CurrentControl) Then
  356.     m_CurrentControl.Font.Bold = False
  357.     m_CurrentControl = Empty
  358.     Exit Sub
  359.   End If
  360.   ' If a control was passed AND a control has been previously set,
  361.   ' then we need to restore the old control and set the new one.
  362.   If Not IsMissing(O) And Not IsEmpty(m_CurrentControl) Then
  363.     ' if it's the same control again, then we can bail out
  364.     If m_CurrentControl.Name = O.Name Then Exit Sub
  365.     ' if the saved control is "bold", then reset it
  366.     If m_CurrentControl.Font.Bold = True Then m_CurrentControl.Font.Bold = False
  367.     ' if the new control's font is not already bold, then set it
  368.     If Not O.Font.Bold Then MakeCurrentControl O
  369.   ' otherwise, it may be the first object being handled,
  370.   ' so set its font to bold
  371.   ElseIf Not IsMissing(O) And IsEmpty(m_CurrentControl) Then
  372.     MakeCurrentControl O
  373.   End If
  374.   Exit Sub
  375. HandleMouseMove_ErrHdlr:
  376.   Debug.Print "ERROR: " & Err.Description
  377. End Sub ' HandleMouseMove
  378. Sub MakeCurrentControl(O As Variant)
  379. ' Make the passed in control the "current" control,
  380. ' make its caption bold and give it the input focus
  381.   On Error GoTo MakeCurrentControl_ErrHdlr
  382.   Set m_CurrentControl = O
  383.   O.Font.Bold = True
  384.   If frmFTP.ActiveControl.Name <> O.Name Then
  385.     O.SetFocus
  386.   End If
  387. MakeCurrentControl_ErrHdlr:
  388. End Sub
  389. Private Sub cmdQuit_Click()
  390.   ' If we're logged in, then logout before ending...
  391.   If cFTP.bLoggedIn() Then
  392.     If Not cFTP.bLogout() Then
  393.       UpdateStatus cFTP.sGetLastError(), vbRed
  394.     End If
  395.   End If
  396.   Set frmFTP = Nothing
  397.   End
  398. End Sub
  399. Private Sub cmdQuit_GotFocus()
  400.   HandleMouseMove cmdQuit
  401. End Sub
  402. Private Sub cmdQuit_LostFocus()
  403.   HandleMouseMove
  404. End Sub
  405. Private Sub cmdQuit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  406.   HandleMouseMove cmdQuit
  407. End Sub
  408. Private Sub Dir1_Change()
  409.   File1.Path = Dir1.Path
  410. End Sub
  411. Private Sub Dir1_DragDrop(Source As Control, X As Single, Y As Single)
  412.   HandleLocalDragDrop Source
  413. End Sub
  414. Private Sub Dir1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  415.   HandleValidDropTarget Dir1
  416. End Sub
  417. Private Sub Drive1_Change()
  418.   Dir1.Path = Drive1.Drive
  419. End Sub
  420. Private Sub File1_DragDrop(Source As Control, X As Single, Y As Single)
  421.   HandleLocalDragDrop Source
  422. End Sub
  423. Private Sub HandleLocalDragDrop(Source As Control)
  424. ' Transfer remote file to local dir
  425.   Dim iResponse As Integer, iStyle As Integer, sMsg As String, sTitle As String
  426.   Dim sLocalFileName As String, sRemoteFileName As String, i As Integer
  427.   On Error Resume Next
  428.   If Source.Name = "File1" Or Source.Name = "Dir1" Then Exit Sub ' don't allow drop on self
  429.   iStyle = vbYesNo + vbQuestion + vbDefaultButton2
  430.   sTitle = "Transfer Remote File"
  431.   ' Loop thru all the selected files...
  432.   For i = 0 To lstFiles.ListCount - 1
  433.     If lstFiles.Selected(i) Then
  434.       If Right(File1.Path, 1) <> "\" Then
  435.         sLocalFileName = File1.Path & "\" & lstFiles.List(i)
  436.       Else
  437.         sLocalFileName = File1.Path & lstFiles.List(i)
  438.       End If
  439.       sRemoteFileName = lstFiles.List(i)
  440.       m_lFileSize = FTP.Files(sRemoteFileName).FileSize ' determine the size of the remote file
  441.       If chkConfirm = vbChecked Then
  442.         sMsg = "Copy " & sRemoteFileName & " [" & m_lFileSize & " bytes] to " & File1.Path & "?"
  443.         iResponse = MsgBox(sMsg, iStyle, sTitle)
  444.       Else
  445.         iResponse = vbYes
  446.       End If
  447.       If iResponse = vbYes Then    ' User chose Yes.
  448.         GetRemoteFile sLocalFileName, sRemoteFileName
  449.       End If
  450.     End If
  451.   Next i
  452. End Sub ' HandleLocalDrop
  453. Private Sub File1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  454.   HandleValidDropTarget Source
  455. End Sub
  456. Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  457.   If File1.ListIndex >= 0 And cFTP.bLoggedIn Then
  458.      File1.DragIcon = imgDragStart.Picture
  459.      File1.Drag
  460.    End If
  461. End Sub
  462. Private Sub HandleInvalidDropTarget(C As Control)
  463.   C.DragIcon = imgInvalid
  464. End Sub
  465. Private Sub HandleValidDropTarget(C As Control)
  466.   C.DragIcon = imgDragStart
  467. End Sub
  468. Private Sub GetRemoteFile(sLocalFileName As String, sRemoteFileName As String)
  469.       
  470.    Dim bBinaryFile As Boolean
  471.   On Error Resume Next
  472.   ' Handle special case of 0 len files...
  473.   If m_lFileSize = 0 Then
  474.     UpdateStatus sRemoteFileName & " is a zero length file.  Aborting operation", vbRed
  475.     Exit Sub
  476.   End If
  477.   ' Update UI...
  478.   PercentGauge.Text = 0
  479.   UpdateStatus "Transfering " & sRemoteFileName & "..."
  480.   bBinaryFile = (chkBinary.Value = vbChecked)
  481.   ' Use the wrapper class to perform the file transfer from the remote system...
  482.   If Not cFTP.bGetFile(sLocalFileName, sRemoteFileName, bBinaryFile) Then
  483.     UpdateStatus "File transfer failed - " & cFTP.sGetLastError, vbRed
  484.   Else
  485.     UpdateStatus "Ready"
  486.     File1.Refresh  ' update file list to reflect the new file
  487.   End If
  488.   ' Hide the percent gauge
  489.   PercentGauge.Text = 0
  490.   m_lFileSize = 0
  491. End Sub ' GetRemoteFile
  492. Private Sub PutLocalFile(sLocalFileName As String, sRemoteFileName As String)
  493.   Dim bSuccess As Boolean, bBinaryFile As Boolean
  494.   On Error Resume Next
  495.   ' Update UI
  496.   PercentGauge.Text = 0
  497.   UpdateStatus "Transfering " & sLocalFileName & "..."
  498.   DoEvents
  499.   bBinaryFile = (chkBinary.Value = vbChecked)
  500.   ' Use the wrapper class to perform the file transfer to the remote system...
  501.   bSuccess = cFTP.bPutFile(sLocalFileName, sRemoteFileName, bBinaryFile)
  502.   ' Update UI and report results...
  503.   PercentGauge.Text = 0
  504.   If Not bSuccess Then
  505.     UpdateStatus "File transfer failed - " & cFTP.sGetLastError, vbRed
  506.   Else
  507.     UpdateStatus "Ready"
  508.     If chkAutoUpdate.Value = vbChecked Then
  509.       GetDirectory ' update directory listing to reflect new file
  510.     End If
  511.   End If
  512.   m_lFileSize = 0
  513. End Sub ' PutLocalFile
  514. Private Sub fmOptions_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  515.   HandleMouseMove
  516. End Sub
  517. Private Sub Form_Load()
  518.   On Error Resume Next
  519.   Dim bSuccess As Boolean
  520.   ' Set initial login values in the FTP control...
  521.   With FTP
  522.     Set .DirectoryListBoxName = lstDirs
  523.     Set .FileListBoxName = lstFiles
  524.     .LoginName = "anonymous"
  525.     .Password = "someone@someplace.com"
  526.     .HostName = "ftp.progress.com"
  527.     .WorkingDirectory = "/"
  528.   End With
  529.   ' Now Initialize the FTP wrapper class by passing it the FTP control
  530.   ' This MUST be done before any of the other wrapper functions can be called,
  531.   ' so you should do this at startup (in form load, sub main, etc)
  532.   bSuccess = cFTP.bInit(FTP)
  533.   If Not bSuccess Then
  534.     UpdateStatus cFTP.sGetLastError(), vbRed
  535.     MsgBox "ERROR: Unable to initialize FTP class module!"
  536.     ShutDown
  537.   End If
  538.   ' Set the initial drive/path values for the local file viewing controls...
  539.   Drive1.Drive = "C"
  540.   Dir1.Path = "C:\TEMP"
  541.   PercentGauge.Text = 0
  542. End Sub
  543. Public Sub ShutDown()
  544.   ' Do other shut down related stuff here
  545.   End
  546. End Sub ' ShutDown
  547. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  548.   HandleMouseMove
  549. End Sub
  550. Private Sub FTP_AccessControlPacketReceived(ByVal Packet As String)
  551.   ' forward the event to the wrapper class...
  552.   cFTP.AccessControlPacketReceived Packet
  553. End Sub
  554. Private Sub FTP_DataControlPacketReceived(ByVal Packet As String, ByVal bytes_in As Integer)
  555.   ' forward the event to the wrapper class...
  556.   cFTP.DataControlPacketReceived Packet, bytes_in
  557.   ' Update the percent meter if a file transfer is underway...
  558.   Dim iPercent As Integer
  559.   If m_lFileSize > 0 Then
  560.     iPercent = CInt((cFTP.lTotalDataBytesIn / m_lFileSize) * 100)
  561.     If iPercent > 100 Then iPercent = 100
  562.     PercentGauge.Text = iPercent '.FloodPercent = iPercent
  563.     PercentGauge.Refresh
  564.   End If
  565. End Sub
  566. Private Sub FTP_DataControlPacketSent(ByVal bytes_out As Integer)
  567.   ' forward the event to the wrapper class...
  568.   cFTP.DataControlPacketSent bytes_out
  569.   ' Update the percent meter if a file transfer is underway...
  570.   Dim iPercent As Integer
  571.   If m_lFileSize > 0 Then
  572.     iPercent = CInt((cFTP.lTotalDataBytesOut / m_lFileSize) * 100)
  573.     If iPercent > 100 Then iPercent = 100 ' make sure we don't overflow
  574.     PercentGauge.Text = iPercent
  575.     PercentGauge.Refresh
  576.     DoEvents ' Allow user to click on "Abort" button
  577.   End If
  578. End Sub
  579. Private Sub FTP_EventStateChanged(ByVal State As Integer)
  580.   ' forward the event to the wrapper class...
  581.   cFTP.EventStateChanged State
  582. End Sub
  583. Private Sub FTP_InternetError(ByVal error_number As Long, ByVal error_message As String)
  584.   ' forward the event to the wrapper class...
  585.   cFTP.InternetError error_number, error_message
  586. End Sub
  587. Private Sub FTP_ServerResponse(ByVal ResponseCode As Integer, ByVal ResponseString As String)
  588.   ' forward the event to the wrapper class...
  589.   cFTP.ServerResponse ResponseCode, ResponseString
  590. End Sub
  591. Private Sub FTP_WSAError(ByVal error_number As Integer)
  592.   ' forward the event to the wrapper class...
  593.   cFTP.WSAError error_number
  594. End Sub
  595. Private Sub lstDirs_DblClick()
  596.   ' change directories as specified by the WorkingDirectory property...
  597.   With FTP
  598.     If .WorkingDirectory = "/" Then
  599.       .WorkingDirectory = "/" & lstDirs.List(lstDirs.ListIndex)
  600.     Else
  601.       .WorkingDirectory = .WorkingDirectory & "/" & lstDirs.List(lstDirs.ListIndex)
  602.     End If
  603.   End With
  604.   UpdateStatus "Setting WorkingDirectory to: " & FTP.WorkingDirectory
  605.   If Not cFTP.bGetDirectory() Then
  606.     UpdateStatus cFTP.sGetLastError, vbRed
  607.   Else
  608.     UpdateStatus "Ready"
  609.     UpdatePath
  610.   End If
  611. End Sub
  612. Private Sub lstDirs_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  613.   HandleMouseMove
  614. End Sub
  615. Private Sub lstFiles_DragDrop(Source As Control, X As Single, Y As Single)
  616.   HandleRemoteDragDrop Source
  617. End Sub
  618. Private Sub HandleRemoteDragDrop(Source As Control)
  619. ' Transfer local file to ftp server
  620.   Dim iResponse As Integer, iStyle As Integer, sMsg As String, sTitle As String
  621.   Dim sLocalFileName As String, sRemoteFileName As String, i As Integer
  622.   On Error Resume Next
  623.   If Source.Name = "lstFiles" Then Exit Sub  ' don't allow drop on self
  624.   iStyle = vbYesNo + vbQuestion + vbDefaultButton2
  625.   sTitle = "Transfer Local File"
  626.   ' Loop thru all the selected files...
  627.   For i = 0 To File1.ListCount - 1
  628.     If File1.Selected(i) Then
  629.       If Right(File1.Path, 1) <> "\" Then
  630.         sLocalFileName = File1.Path & "\" & File1.List(i)
  631.       Else
  632.         sLocalFileName = File1.Path & File1.List(i)
  633.       End If
  634.       sRemoteFileName = File1.List(i)
  635.       m_lFileSize = FileLen(sLocalFileName) ' determine the length of the file being sent
  636.       If chkConfirm.Value = vbChecked Then
  637.         sMsg = "Copy " & sLocalFileName & " [" & m_lFileSize & " bytes] to " & FTP.WorkingDirectory & "?"
  638.         iResponse = MsgBox(sMsg, iStyle, sTitle)
  639.       Else
  640.         iResponse = vbYes
  641.       End If
  642.       If iResponse = vbYes Then    ' User chose Yes.
  643.         PutLocalFile sLocalFileName, sRemoteFileName
  644.       End If
  645.     End If
  646.   Next i
  647. End Sub
  648. Private Sub lstFiles_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  649.   HandleValidDropTarget Source
  650. End Sub
  651. Private Sub lstFiles_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  652.    If lstFiles.ListIndex >= 0 Then
  653.      lstFiles.DragIcon = imgDragStart
  654.      lstFiles.Drag
  655.    End If
  656. End Sub
  657. Private Sub lstFiles_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  658.   HandleMouseMove
  659. End Sub
  660. Private Sub SSFrame1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  661.   HandleInvalidDropTarget Source
  662. End Sub
  663. Private Sub SSFrame2_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
  664.   HandleInvalidDropTarget Source
  665. End Sub
  666. Private Sub SSFrame2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  667.   HandleMouseMove
  668. End Sub
  669. Private Sub txtStatus_KeyPress(KeyAscii As Integer)
  670.   KeyAscii = 0 ' trap user input
  671. End Sub
  672.